package com.example.user.service;


import com.example.user.common.Result;
import com.example.user.entity.CommunityActivity;
import com.example.user.entity.Favorite;
import com.example.user.mapper.ActivityDetailInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityDetailInfoService {




    @Autowired
    private ActivityDetailInfoMapper activityDetailInfoMapper;

    public List<CommunityActivity> selectDetail() {
       List<CommunityActivity> communityActivityList= activityDetailInfoMapper.selectDetail();
       return communityActivityList;
    }

    public List<CommunityActivity> selectActivityById(Integer activityId) {
     List< CommunityActivity >communityActivity=  activityDetailInfoMapper.selectActivityById(activityId);
      return communityActivity;
    }

    public Result addFavorite(Favorite favorite) {

      int count=  activityDetailInfoMapper.addFavorite(favorite);
      if(count==0)
      {
          return Result.error("400","收藏失败");
      }

      return Result.success("收藏成功");

    }

    public Result selectFavoriteById(Integer activityId) {

       Favorite favorite= activityDetailInfoMapper.selectFavoriteById(activityId);
       return Result.success(favorite);
    }
}
